import re

'''
*XXX*		=>	<strong>XXX</strong>
_XXX_		=>	<em>XXX</em>
-XXX-		=>	<del>XXX</del>
*-_XXX_-*	=>	<strong><del><em>XXX</em></del></strong>
'''
str_map = {
	'*': 'strong',
	'_': 'em',
	'-': 'del'
	}


def encode_str (str):
	output_str = ''
	stack = []
	for ch in str:
		if str_map.has_key(ch):
			if stack == [] or ch not in stack:
				output_str += '<' + str_map[ch] + '>'
				stack.append(ch)
			elif ch == stack[-1]:
				output_str += '</' + str_map[ch] + '>'
				stack.pop()
			else:
				return str
		else:
			output_str += ch
	if stack != []:
		return str
	return output_str

def main ():
	tip = 'input raw string, q means quit: '
	pat = r'[\-\*\_\w]+'
	str = raw_input(tip)
	while str != 'q':
		print ' '.join( [encode_str(str) for str in re.findall(pat, str)] )
		str = raw_input(tip)

if __name__ == '__main__':
	main()


